package io.gimo.study.design_pattern.factory.abstract_factory.product;


import io.gimo.study.design_pattern.factory.abstract_factory.Sortor;

import java.util.Arrays;

public class SelectSortor implements Sortor {

	@Override
	public void sort(int[] target) {
		for (int i = 0; i < target.length; i++) {
			int min = target[i];
			int pos = i;
			for (int j = i + 1; j < target.length; j++) {
				if(target[j]<min){
					min = target[j];
					pos = j;
				}
			}
			// 交换i和j上元素的位置
			target[pos] = target[i];
			target[i] = min;
		}
		System.out.println(Arrays.toString(target));
	}

}
